//
//  V2TopicCell.m
//  V2EX
//
//  Created by 花菜ChrisCai on 2016/6/12.
//  Copyright © 2016年 Chris. All rights reserved.
//

#import "V2TopicCell.h"
#import "V2TopicModel.h"
#import "UIImageView+WebCache.h"
@interface V2TopicCell ()
/** 标题 */
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
/** 头像 */
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
/** 时间 */
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
/** 昵称 */
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
/** 来源 */
@property (weak, nonatomic) IBOutlet UILabel *sourceLabel;
@end
@implementation V2TopicCell

- (void)awakeFromNib {
    // Initialization code
//    self.autoresizingMask = UIViewAutoresizingNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(V2TopicModel *)model
{
    _model = model;
    
    self.nameLabel.text = model.userName;
    NSString *time = nil;
    if ([model.createdDate isEqualToString:@"几秒前"]) {
        time = @"刚刚";
    }else {
        time = model.createdDate;
    }
    self.timeLabel.text = time;
    self.titleLabel.text= model.articleTitle;
    self.sourceLabel.text = model.nodeName;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:[V2HTTP stringByAppendingString:model.userAvatar]] placeholderImage:[UIImage imageNamed:@"default_avatar"]];
}
@end
